package Top200;

/**
 * @author zhangmin
 * @create 2022-02-23 10:18
 * 贪心
 */
public class canJump55 {
    public boolean canJump(int[] nums) {
        int n=nums.length,farthest=0;
        if (n<=1) return true;
        for (int i = 0; i < n-1; i++) {
            farthest=Math.max(farthest,i+nums[i]);
            if (farthest<=i){
                return false;
            }
        }
        return farthest>=n-1;
    }
}
